public class PrintPrimes {
    public static void main(String[] args) {
        boolean isPrime;
        int count = 0;
        for(int i = 2; i < 2000; i++){
            isPrime = true;
            for (int j = 2; j < i; j++){
                if(i%j == 0)
                    isPrime = false;
            }
            if (isPrime == true){
                System.out.print(i+" ");
                count++;
            }
            if (count == 5){
                System.out.println();
                count = 0;
            }
        }

    }
}